package com.ruoyi.third.service;

import cn.hutool.core.util.StrUtil;
import com.ruoyi.domain.base.Bmxx;
import com.ruoyi.domain.base.BmxxInstance;
import com.ruoyi.domain.base.PageDomain;
import org.springframework.stereotype.Service;

import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

@Service
public class BmxxService
{

    public List<Bmxx> getList() {
        return BmxxInstance.getList();
    }


    public PageDomain<Bmxx> getByPage(String spmc, Integer page, Integer rows) {
        List<Bmxx> data = BmxxInstance.getList();
        if (StrUtil.isNotBlank(spmc)) {
            data = BmxxInstance.getList().parallelStream().filter(e -> e.getSPMC().contains(spmc)).sorted(Comparator.comparing(Bmxx::getSPBM)).collect(Collectors.toList());
        }
        return PageDomain.build(page, rows, data);
    }
}
